package com.yxinsur.imc.web.controller.business;

import com.yxinsur.imc.business.domain.ImcFundBrokerVariable;
import com.yxinsur.imc.business.service.IImcFundBrokerVariableService;
import com.yxinsur.imc.common.annotation.Log;
import com.yxinsur.imc.common.core.controller.BaseController;
import com.yxinsur.imc.common.core.domain.AjaxResult;
import com.yxinsur.imc.common.core.page.TableDataInfo;
import com.yxinsur.imc.common.enums.BusinessType;
import com.yxinsur.imc.common.utils.poi.ExcelUtil;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 人员口径变量(对应下拉列应显示的内容)Controller
 *
 * @author imc
 * @date 2021-10-29
 */
@RestController
@RequestMapping("/business/fund/broker/variable")
public class ImcFundBrokerVariableController extends BaseController {
    @Autowired
    private IImcFundBrokerVariableService imcFundBrokerVariableService;

    /**
     * 查询口径变量
     */
    @ApiOperation("查询人员口径变量")
    @GetMapping("/list")
    public AjaxResult listVariable() {
        return AjaxResult.success(this.imcFundBrokerVariableService.listVariable());
    }

    /**
     * 导出人员口径变量(对应下拉列应显示的内容)列表
     */
    @PreAuthorize("@ss.hasPermi('system:variable:export')")
    @Log(title = "人员口径变量(对应下拉列应显示的内容)", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(ImcFundBrokerVariable imcFundBrokerVariable) {
        List<ImcFundBrokerVariable> list = imcFundBrokerVariableService.selectImcFundBrokerVariableList(imcFundBrokerVariable);
        ExcelUtil<ImcFundBrokerVariable> util = new ExcelUtil<ImcFundBrokerVariable>(ImcFundBrokerVariable.class);
        return util.exportExcel(list, "variable");
    }

    /**
     * 获取人员口径变量(对应下拉列应显示的内容)详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:variable:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(imcFundBrokerVariableService.selectImcFundBrokerVariableById(id));
    }

    /**
     * 新增人员口径变量(对应下拉列应显示的内容)
     */
    @PreAuthorize("@ss.hasPermi('system:variable:add')")
    @Log(title = "人员口径变量(对应下拉列应显示的内容)", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ImcFundBrokerVariable imcFundBrokerVariable) {
        return toAjax(imcFundBrokerVariableService.insertImcFundBrokerVariable(imcFundBrokerVariable));
    }

    /**
     * 修改人员口径变量(对应下拉列应显示的内容)
     */
    @PreAuthorize("@ss.hasPermi('system:variable:edit')")
    @Log(title = "人员口径变量(对应下拉列应显示的内容)", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ImcFundBrokerVariable imcFundBrokerVariable) {
        return toAjax(imcFundBrokerVariableService.updateImcFundBrokerVariable(imcFundBrokerVariable));
    }

    /**
     * 删除人员口径变量(对应下拉列应显示的内容)
     */
    @PreAuthorize("@ss.hasPermi('system:variable:remove')")
    @Log(title = "人员口径变量(对应下拉列应显示的内容)", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(imcFundBrokerVariableService.deleteImcFundBrokerVariableByIds(ids));
    }
}
